package com.usts.edu.studenttemp.mapper;

import com.usts.edu.studenttemp.dto.*;

import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface TemperatureMapper {
    int countByExample(TemperatureExample example);

    int deleteByExample(TemperatureExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(Temperature record);

    int insertSelective(Temperature record);

    List<Temperature> selectByExample(TemperatureExample example);

    Temperature selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Temperature record, @Param("example") TemperatureExample example);

    int updateByExample(@Param("record") Temperature record, @Param("example") TemperatureExample example);

    int updateByPrimaryKeySelective(Temperature record);

    int updateByPrimaryKey(Temperature record);

    List<StudentTemperature> selectTemperatureByUserId(ResqStudentTemperature stemperature);

    @Select("SELECT t.id, t.temp as temperature FROM temperature t  where IF(DATE_FORMAT(now(),\"%H:%i:%s\")<'11:00:00',t.createtime >= CONCAT(DATE_FORMAT(DATE_SUB(now(),INTERVAL 0 DAY),'%Y-%m-%d'),' 6:00:00') AND t.createtime <= CONCAT(DATE_FORMAT(DATE_SUB(now(),INTERVAL 0 DAY ),'%Y-%m-%d'),' 11:00:00') ,t.createtime >= CONCAT(DATE_FORMAT(DATE_SUB(now(),INTERVAL 0 DAY),'%Y-%m-%d'),' 11:00:00') AND t.createtime <= CONCAT(DATE_FORMAT(DATE_SUB(now(),INTERVAL 0 DAY ),'%Y-%m-%d'),' 21:00:00')) and t.student_id =#{stuid}")
    ResqGetStudentTemperature selectStudentTempByStuid(Integer stuid);

    List<AdminStudentTemperatureShow> selectAllStudentTemp(AdminStudentTemperature studentTemperature);
}